
/*
 * This is an integration test
 * of someone creating a game and
 * waiting for player to join.
 *
 * The game is run sychronously
 * I choose this cause its easier
 * Its possible that threads might be used
 * to make it flow better and not freeze the game
 * But for now I am leaving them out
 *
 * This is a rought draft of the flow of the game
 */

void Connection::test_gameFlow()
{
    Game.game();
    // Creates a game and
    // shows IP and Port for player to join
    // The client would call game.join()
    game.create();
    // The requirements wants the ability to add a map
    // and read from unit cards
    game.loadTypesOfUnitsAndGameMaps();
    // Waits a set amount of time
    // if someone joins it continues
    // if not it gives some sort of dialog on what to do
    game.waitForPlayerToJoin();
    // Shows a screen to each player on picking
    // which side to play
    // Each command should at like a monitor
    // Everytime makes a choice at the end
    // it should said what they choose through the connection
    game.pickArmyType();
    game.pickWarCaster();
    game.pickOtherUnits();

    while (!game.done) {
        // Normally this would just be a function call for
        // game.runIt()
        // But it is expanded so it can fit in one test

        // This awaits for the player to determine what to do
        // It'll set some condition called action
        game.determineMove();
        // This executes the move if it is legal
        // It then sends the action made through the connection
        // it will be updated on the client
        game.determineIfMoveAcceptable(); 
        // This will wait for the opponent to move
        // It will have a timer so that it doesn't freeze the game
        // Ideally this would be a thread so it doesn't freeze the UI
        game.awaitOpponentMove();
    }
}
